// 引入express框架
const express = require('express')
const cors = require('cors')
// 引入路由对象
const {userRouter} = require('./router/user.js')
const {goodsRouter} = require('./router/goods.js')
const {bannerRouter} = require('./router/banner.js')
const {categoryRouter} = require('./router/category.js')
// express实例对象
const app = express()

//集成中间件
app.use(cors())

// 处理body请求体中参数
app.use(express.json())
app.use(express.urlencoded({extended:false}))

app.use(userRouter)
app.use(goodsRouter)
app.use(bannerRouter)
app.use(categoryRouter)

// ip:唯一确定一台电脑的，端口号是唯一确定一个应用
app.listen(3000,()=>console.log('监听3000，启动服务成功!'))